<!DOCTYPE >
<html lang="zh-cn">
<head>
		<title>后台管理-约会举报</title>
    <% include ./partials/head %>
	<script type="text/javascript">
		var odateComplain ={
			type:0,
			operator:function(){
				$(".box-content").on('click','.warn',function(){
					$this = $(this)
					if(window.confirm('你确定警告该用户么？')){
						//认证 0警告，1封号
						$.post("/admin/handleDateComplain",{
							"dateComplainId":$this.attr('dateComplainId'),
							"userId":$this.attr('userId'),
							"dateComplainType":0,
							"content":$(".warnContent").val()
						},function(json){
							if(json.code==0){
								history.go(0) 
							}else{
								alert(json.msg);
							}
						},'json');
					}else{
						//取消
					}
				}).on('click','.closeId',function(){
					$this = $(this)
					if(window.confirm('你确定要封禁该帐号么？')){
						//封禁 
						$.post("/admin/handleDateComplain",{
							"dateComplainId":$this.attr('dateComplainId'),
							"userId":$this.attr('userId'),
							"dateComplainType":1
						},function(json){
							if(json.code==0){
								history.go(0) 
							}else{
								alert(json.msg);
							}
						},'json');
					}else{
						//取消
					}
				}).on('click','.forbiddenId',function(){
					$this = $(this)
					if(window.confirm('你确定要禁言该帐号么？')){
						//禁言 
						$.post("/admin/dateComplain",{
							"dateComplainId":$this.attr('dateComplainId'),
							"userId":$this.attr('userId'),
							"dateComplainType":2
						},function(json){
							if(json.code==0){
								history.go(0) 
							}else{
								alert(json.msg);
							}
						},'json');
					}else{
						//取消
					}
				}).on('click','.drawback',function(){
					$this = $(this)
					if(window.confirm('你确定同意退款，并退款至申请人账号？')){
						//拒绝 
						$.post("/admin/dateComplain",{
							"dateComplainId":$this.attr('dateComplainId'),
							"userId":$this.attr('userId'),
							"dateComplainType":3
						},function(json){
							if(json.code==0){
								history.go(0) 
							}else{
								alert(json.msg);
							}
						},'json');
					}else{
						//取消
					}
				}).on("click",".contact",function(){
					$this = $(this)
					if(window.confirm('你确定要联系他么？')){
						//拒绝 
						$.post("/admin/dateComplainContact",{
							"userId":$this.attr('userId'),
							"content":$(".contactContent").val()
						},function(json){
							if(json.code==0){
								alert(json.msg); 
							}else{
								alert(json.msg);
							}
						},'json');
					}else{
						//取消
					}
				})
			},
			change:function(){
				var state =window.location.href.split("=")[2];
				if(state ==1){
					$(".title_info").html("已处理");
				}else if(state==2){
					$(".title_info").html("已忽略");
				}else{
					$(".title_info").html("未处理");
				}
				$("#dateComplain-filter").on("change",function(){
					var value = $(this).children('option:selected').val(); 
					window.location.href=window.location.origin+"/admin/dateComplain?type="+odateComplain.type+"&status="+value;
				})
			},
			init:function(){
				this.operator();
				this.change();
			}
		}
		$(document).ready(function(){
			if(window.location.href.split("=").length==2){
				var type = window.location.href.split("=")[1];
			}else{
				var type = window.location.href.split("=")[1].split("&")[0];
			}
			odateComplain.type =type;
			odateComplain.init();
		})
	</script>
</head>
<body>
	<header>
      <% include ./partials/header %>
	</header>
  <div class="ch-container">
    <% include ./partials/sidebar %>
    <!-- 页面内容 -->
    <!-- 页面内容 -->
    <div id="content" class="col-lg-10 col-sm-10">
        <div class="row">
          <div class="box col-md-12">
            <div class="box-inner">
              <div class="box-header well" data-original-title="">
                <div class="control-group">
                  <div class="controls">
                    <label class="control-label" for="selectError">筛选:&nbsp&nbsp&nbsp </label>
                    <select id="dateComplain-filter" data-rel="chosen">
                    	<option>选择</option>
                        <option value="0">未处理</option>
                        <option value="1" >已处理</option>
                        <option value="2">已忽略</option>
                    </select>
                  </div>
                  
                </div>
              </div>

              <div class="box-content">
              	<div class="alert alert-info center title_info"></div>
                <table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
                  <thead>
                    <tr>
                      <th></th>
                      <th>投诉人</th>
                      <th>投诉人ID</th>
                      <th>被报投诉人</th>
                      <th>被投诉人ID</th>
                      <th>备注</th>
                      <th>截图</th>
                      <th>退款金额</th>
                      <th>时间</th>
                      <th>处理状况</th>
                    </tr>
                  </thead>

                  <tbody>
                    <% if (typeof dateComplains != "undefined") { %>
                      <% dateComplains.forEach(function(dateComplain,index) { %>
                        <tr>
                          <td class="center"><%=index%></td>	
                          <td class="center"><a href="/admin/userinfo?userId=<%= dateComplain.get('belongDate').get('sponsor').id%>"><%= dateComplain.get('belongDate').get('sponsor').get("nickname") %></a>
                          	<p><input class="contactSponsor" type="text" placeholder="联系他">
					      		<span class="btn btn-success contact " userId=<%= dateComplain.get('belongDate').get('sponsor').id%>>
	                              <i class="glyphicon glyphicon-warning-sign icon-white"></i>
	                             联系他
	                          	</span></p></td>
                          <td class="center"><%= dateComplain.get('belongDate').get('sponsor').get("molianId") %></td>
                          <td class="center"><a href="/admin/userinfo?userId=<%= dateComplain.get('belongDate').get('winner').id%>"><%= dateComplain.get('belongDate').get('winner').get("nickname") %></a></td>
                          <td class="center"><%= ddateComplain.get('belongDate').get('winner').get("molianId") %></td>
                          <td class="center"><%= dateComplain.get("remark") %></td>
                          <td class="center">
                              <% if (typeof dateComplain.get('img') != "undefined") { %>
                              <a  href="<%=dateComplain.get('img').url()%>" target="_blank"> <img style="max-height:100px" src="<%=dateComplain.get('img').url()%>"></a>
                              <% } %>
                            </td>
                          <td class="center"><%=dateComplain.get('belongDate').get('price')%></td>
                          <td class="center"><%=Format(new Date(dateComplain.createdAt))%></td>
        
                          <td class="center">
  						    <% if(dateComplain.get("status")==1){ %>
					      		<span class="btn">已处理</span>	
					      	<% } %>
					      	<% if(dateComplain.get("status")==2){ %>
					      		<span class="btn">已忽略</span>	
					      	<% } %>
					      	<% if(dateComplain.get("status")==0){ %>
					      		<input class="warnContent" type="text" placeholder="警告内容">
					      		<span class="btn btn-success warn " dateComplainId=<%=dateComplain.id%> userId=<%=dateComplain.get('belongDate').get("winner").id%>>
	                              <i class="glyphicon glyphicon-warning-sign icon-white"></i>
	                             警告
	                          	</span>
	                          	<span class="btn btn-danger closeId" dateComplainId=<%=dateComplain.id%> userId=<%=dateComplain.get('belongDate').get("winner").id%>>
	                              <i class="glyphicon glyphicon-remove icon-white"></i>
	                             封号
	                          	</span>
	                          	<span class="btn btn-danger drawback" dateComplainId=<%=dateComplain.id%> userId=<%=dateComplain.get('belongDate').get("sponsor").id%>>
	                              <i class="glyphicon glyphicon-volume-off icon-white"></i>
	                             退款
	                          	</span>
	                          	<span class="btn btn-info pass"  dateComplainId=<%=dateComplain.id%> userId=<%=dateComplain.get('belongDate').get("winner").id%>>
	                              <i class="glyphicon glyphicon-ban-circle icon-white"></i>
	                             忽略 
	                          	</span>
	                          	
					      	<% } %>

                            
                          </td>
                        </tr>
                      <% }) %>
                    <% } %>
                  </tbody>
                </table>
              </div>

            </div>
          </div>
        </div>
      </div> 
    <% include ./partials/footer %>
  </div>
  <% include ./partials/external %>
</body>
</html>
